package com.cskaoyan.config1;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

/**
 * 没有使用到配置文件里的值
 * @author stone
 * @date 2022/07/15 10:20
 */
@Configuration
public class DataSourceConfiguration1 {

    /*@Bean
    public DataSource dataSource1() {
        DruidDataSource dataSource = new DruidDataSource();
        String driverClassName = "com.mysql.jdbc.Driver";
        dataSource.setDriverClassName(driverClassName);
        String url = "jdbc:mysql://localhost:3306/cskaoyan_db?useUnicode=true&characterEncoding=utf-8";
        dataSource.setUrl(url);
        String username = "root";
        dataSource.setUsername(username);
        String password = "123456";
        dataSource.setPassword(password);
        return dataSource;
    }*/
    String driverClassName = "com.mysql.jdbc.Driver";
    String url = "jdbc:mysql://localhost:3306/cskaoyan_db?useUnicode=true&characterEncoding=utf-8";
    String username = "root";
    String password = "123456";
    @Bean
    public DataSource dataSource1() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setDriverClassName(driverClassName);
        dataSource.setUrl(url);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }
}
